package com.atguigu.guilimall.cart.vo;

import java.math.BigDecimal;
import java.util.List;

public class Cart {
    /**
     * 所有的购物项
     */
    private List<CartItem> items;
    /**
     * 商品数量
     */
    private Integer countNum;
    /**
     * 商品类型
     */
    private Integer countType;
    /**
     * 减免价格
     */
    private BigDecimal reduce = new BigDecimal("0.00");//减免价格

    public BigDecimal getTotalAmount() {
        BigDecimal amount = new BigDecimal("0");
        for (CartItem item : items) {
            amount = amount.add(item.getTotalPrice());
        }
        amount = amount.subtract(reduce);
        return amount;
    }

    private BigDecimal totalAmount;//商品总价
    public List<CartItem> getItems() {
        return items;
    }

    public void setItems(List<CartItem> items) {
        this.items = items;
    }

    public Integer getCountNum() {
        int count = 0;
        if (items.size()>0&&items != null){
            for (CartItem item : items) {
               count += item.getCount();
            }
        }
        return count;
    }

    public Integer getCountType() {
        int count = 0;
        if (items.size()>0&&items != null){
            count=items.size();
        }
        return count;
    }


    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }

}
